package uutalk.netcloud.talk.base.mqtt.model;

import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.json.JSONObject;

import uutalk.netcloud.talk.base.util.TimeUtil;

/**
 * ClassName: EmqMessage
 * Desc:
 * Created by zhiw on 2017/3/27.
 */

public class EmqMessage {

    private String cmd;
    private MqttMessage mqttMessage;
    private String updateTime;

    public EmqMessage(String cmd, MqttMessage mqttMessage) {
        this.cmd = cmd;
        this.mqttMessage = mqttMessage;
        this.updateTime = TimeUtil.formatNow();
    }

    public String getCmd() {
        return cmd;
    }

    @Override
    public String toString() {
        if (mqttMessage != null) {
            return mqttMessage.toString();
        }
        return new JSONObject().toString();
    }

    public void setCmd(String cmd) {
        this.cmd = cmd;
    }

    public MqttMessage getMqttMessage() {
        return mqttMessage;
    }

    public void setMqttMessage(MqttMessage mqttMessage) {
        this.mqttMessage = mqttMessage;
    }

    public String getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(String updateTime) {
        this.updateTime = updateTime;
    }
}
